<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			#box1{
				width: 100px;
				height: 70px;
				border: 1px solid green;
				background-color: blueviolet;
				position: absolute;
			}
		</style>
		<script type="text/javascript">
			window.onload=function(){
				var box1=document.getElementById("box1");
				document.onmousemove=function(event){
					/*box1.style.left=event.pageX+"px";
					box1.style.top=event.pageY+"px";*//*IE8不支持*/
					event=event||window.event;/*IE8的event在window中*/
					var st=document.body.scrollTop || document.documentElement.scrollTop;/*chrome的滚动条在body中，其他浏览器的在整个页面中*/
					var sl=document.body.scrollLeft || document.documentElement.scrollLeft;/*chrome的滚动条在body中，其他浏览器的在整个页面中*/

					box1.style.left=event.clientX+sl+"px";
					box1.style.top=event.clientY+st+"px";
					
					
				};
			};	
		</script>
	</head>
	<body style="height: 1000px;width: 6000px;">
		<div id="box1"></div>
	</body>
</html>
